package com.kingsoft.dc.khaos.extender.meta.impl;

import com.alibaba.fastjson.JSON;
import com.kingsoft.dc.khaos.extender.meta.model.ds.Connect;
import com.kingsoft.dc.khaos.extender.meta.model.ds.PGSqlConnect;
import com.kingsoft.dc.khaos.extender.meta.utils.RSAEncrypt;


public class PGSqlDmMetaImpl extends DmMetaImpl {

    /**
     * 构造PGSqlConnect并对密码加密
     * @param config
     * @return
     */
    @Override
    public Connect decryptDatasourceConnectSecret(String config) {
        PGSqlConnect connect = JSON.parseObject(config, PGSqlConnect.class);
        try {
            connect.setPassWord(RSAEncrypt.decryptByRSAPassWord(connect.getPassWord()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return connect;
    }

}
